<template>
  <div class="search-main">
    <el-dialog
      title="Search"
      :visible.sync="dialogVisible"
      width="55%"
      :before-close="handleClose"
    >
      <!-- 关键字 -->
      <div class="keyword">
        <el-input v-model="keyword" placeholder="输入关键字...."></el-input>
      </div>
      <!-- 查询列表 -->
      <div class="serach-list" v-if="articleList.length != 0">
        <ul>
          <li v-for="item in articleList" :key="item.articleId">
            <router-link
              :to="{
                path: '/articleDetail',
                query: { articleId: item.articleId },
              }"
              :key="item.articleId"
            >
              <div class="email-left">
                <div class="email-right">
                  <img :src="item.firstPicture" />
                </div>
                <div class="email-more">
                  <h4>{{ item.articleTitle }}</h4>
                  <p>
                    {{ item.articleSummary }}
                  </p>
                  <div class="artcle-icons">
                    <span
                      ><i class="iconfont">&#xe601;</i
                      >{{ item.articleAuthor }}</span
                    >
                    <span
                      ><i class="iconfont">&#xe64d;</i
                      >{{ item.createTime | formatDate }}</span
                    >
                    <span
                      ><i class="iconfont">&#xe670;</i
                      >{{ item.articleViews }}</span
                    >
                    <span
                      ><i class="iconfont">&#xe7f5;</i
                      >{{ item.recommendGrade }}</span
                    >
                  </div>
                </div>
              </div>
            </router-link>
          </li>
        </ul>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  components: {},
  name: "search",
  props: ["dialogVisible"],
  data() {
    return {
      keyword: "",
      articleList: [],
    };
  },
  created() {},
  // 创建一个过滤器
  filters: {},
  methods: {
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          // 将数据传输给父亲
          this.$emit("closeDialog");
        })
        .catch((_) => {});
    },
  },
};
</script>

<style>
.search-main {
  margin: 80px auto;
}
.el-dialog__title {
  margin-left: 45% !important;
}

.el-dialog__header {
  border-bottom: 1px solid #c7c3bd;
}
.el-input__inner {
  border: none;
  border-bottom: 2px solid #149898;
}
</style>
